﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Linq.Expressions;

namespace Sexybeauty.Test
{
    class Program
    {
        static void Main(string[] args)
        {
            Method<object>(c => c.Username == "abc");
            Method<object>(c => c.Username == "abc" && c.Age == 1 && c.Gender == 1);
        }
        static void Method<T>(Expression<Func<Body,bool>> predicate)
        {
            if (predicate.Parameters.Count == 1)
            {
                string expressionParam = predicate.Parameters[0].Name;
                var be = predicate.Body as BinaryExpression;
                if (be.Left.NodeType == ExpressionType.MemberAccess &&
                    be.Right.NodeType == ExpressionType.Constant)
                {
                    var filed = be.Left.ToString().Replace(expressionParam + ".", "");
                    var val = (be.Right as ConstantExpression).Value;
                }
            }
        }
    }
    public class Body
    {
        public string Username { get; set; }
        public int Age { get; set; }
        public int Gender { get; set; }
    }
}
